library(devtools)
source_url("https://gitee.com/ry2an/my_public_functions_r/raw/master/write_file.R")
pandoc_code_gene <- function(
    source_name = ".md", 
    out_name =  "out.docx",
    referpath = "",
    reference = "custom_reference.docx",
    return_code = F){
  if(referpath != ""){
    cur_wd <- getwd()
    setwd(referpath)
  }else{
    cur_wd <- getwd()
  }
  out_str <- paste("pandoc ", getwd(), "/", source_name,
                   " -o ", getwd(), "/", out_name,
                   " --reference-doc ", getwd(), "/", reference, ";",sep = "")
  write_file(file_name = paste("run.sh", sep = ""), contents = out_str)
  setwd(cur_wd)
  if(return_code){
    return(out_str)
  }
}



# pandoc_code_gene(source_name = "test.md", out_name = "doc.docx", return_code = T)
